package com.yifang.yibingproject.utils;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import java.io.Serializable;

@Data
@ApiModel(value = "分页查询")
public class PageQuery implements Serializable {

    @Min(1)
    @ApiModelProperty("页码")
    protected int pageNo = 1;

    @Min(1)
    @ApiModelProperty("数量")
    protected int pageSize = 10;

    @ApiModelProperty(value = "数据查询起始下标，自动计算", hidden = true)
    protected int beginIndex;

    public int getBeginIndex() {
        return (pageNo - 1) * pageSize;
    }
}
